home *** CD-ROM | disk | FTP | other *** search
- property Background, Drag, DragPict, IndicatorField, NLevels, CurrentLevel, levelSize, FullHeight, DragHalfHeight, Base
-
- on birth me, backgroundSprite, dragSprite, dragCast, valueField
- set Background to backgroundSprite
- set Drag to dragSprite
- set DragPict to dragCast
- set IndicatorField to valueField
- puppetSprite(Drag, 1)
- set DragHalfHeight to the height of sprite Drag / 2
- set FullHeight to the height of sprite Background - (2 * DragHalfHeight)
- set Base to the locV of sprite Background - DragHalfHeight
- set NLevels to 0
- set CurrentLevel to 0
- set levelSize to float(0)
- set IndicatorField to valueField
- return me
- end
-
- on mSetNumLevels me, numLevels
- set NLevels to numLevels
- set CurrentLevel to numLevels
- set levelSize to float(FullHeight) / float(NLevels)
- end
-
- on mUpdateLevelIndicator me, whichLevel
- set the text of field IndicatorField to string(whichLevel)
- updateStage()
- end
-
- on mSetLevel me, whichLevel
- if (NLevels > 0) and (whichLevel > 0) and (whichLevel <= NLevels) then
- set newHeight to (levelSize * float(whichLevel - 1)) + (levelSize / 2.0)
- set newHeight to integer(newHeight)
- set the locV of sprite Drag to Base - newHeight
- mUpdateLevelIndicator(me, whichLevel)
- set CurrentLevel to whichLevel
- end if
- end
-
- on mGetCurrentLevel me
- return CurrentLevel
- end
-
- on mComputeNewLevel me, dragLocation
- set newLevel to float(Base - dragLocation) / levelSize
- set newLevel to integer(newLevel)
- if newLevel < 1 then
- set newLevel to 1
- else
- if newLevel > NLevels then
- set newLevel to NLevels
- end if
- end if
- return newLevel
- end
-
- on mDragLevel me
- set firstTime to 1
- set offset to the locV of sprite Drag - the mouseV
- repeat while the mouseDown
- if rollOver(Background) or rollOver(Drag) then
- if firstTime then
- set the castNum of sprite Drag to the number of cast DragPict + 1
- updateStage()
- set firstTime to 0
- end if
- set newLoc to the mouseV + offset
- if (newLoc <= Base) and (newLoc >= (Base - FullHeight)) then
- set the locV of sprite Drag to newLoc
- set newLevel to mComputeNewLevel(me, newLoc)
- mUpdateLevelIndicator(me, newLevel)
- else
- if newLoc > Base then
- set the locV of sprite Drag to Base
- set newLevel to mComputeNewLevel(me, Base)
- mUpdateLevelIndicator(me, newLevel)
- else
- if newLoc < (Base - FullHeight) then
- set the locV of sprite Drag to Base - FullHeight
- set newLevel to mComputeNewLevel(me, Base - FullHeight)
- mUpdateLevelIndicator(me, newLevel)
- end if
- end if
- end if
- next repeat
- end if
- if firstTime = 0 then
- set the castNum of sprite Drag to the number of cast DragPict
- updateStage()
- set firstTime to 1
- end if
- end repeat
- end
-
- on mReleaseDrag me
- set the castNum of sprite Drag to the number of cast DragPict
- updateStage()
- set newLevel to mComputeNewLevel(me, the locV of sprite Drag)
- mSetLevel(me, newLevel)
- return newLevel
- end
-
- on mRemoveGaugeUI me
- puppetSprite(Drag, 0)
- set the text of field IndicatorField to " "
- end
-
- on mRestoreGaugeUI me
- puppetSprite(Drag, 1)
- mSetLevel(me, CurrentLevel)
- end
-